package com.ag.lzw.dao;

import java.util.List;

import com.ag.bean.TbTaskFeedback;
import com.ag.dao.TbTaskFeedbackDAO;

public class LzwTbTaskFeedbackDAO extends TbTaskFeedbackDAO {

	public List findByTaskId(String id){
		String hql = "from TbTaskFeedback tf where tf.tbTask.TId='"+id+"'";
		return getHibernateTemplate().find(hql);
	}
	
	public List findNewByTaskId(String id){
		String hql = "from TbTaskFeedback tf " +
				     "where tf.tfCheck = '0' and tf.tbTask.TId='"+id+"'";
		return getHibernateTemplate().find(hql);		
	}
	
	public TbTaskFeedback findByFBId(String fbid){
		String hql = "From TbTaskFeedback as ttf "
		           + "left join fetch ttf.tbTask " 
		           + "where ttf.tfId = '" + fbid + "'";
		List<TbTaskFeedback> list = getHibernateTemplate().find(hql);
		logger.info("TaskFeedback findByFBId result length:"+list.size());
		TbTaskFeedback res = null;
		for(TbTaskFeedback ttf : list){
		    if(ttf!=null){
		    	res = ttf;
		    }
		}
		return res;
	}

	public int getCountofTrack(String tid){
		String hql = "From TbTaskFeedback as ttf left join fetch ttf.tbTask as tt where tt.TId = '"+tid+"'";
		List list = getHibernateTemplate().find(hql);
		return list.size();
	}
	
}
